package com.example.rediscluster;

import com.example.rediscluster.po.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.RedisTemplate;

import java.io.Serializable;

@SpringBootApplication
public class RedisclusterApplication implements CommandLineRunner {

    public static void main(String[] args) {
        SpringApplication.run(RedisclusterApplication.class, args);
    }


    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @Override
    public void run(String... args) throws Exception {
        String key = "user:id:2";
        User user = new User();
        user.setId(1);
        user.setUsername("haha");
        user.setPassword("021998");
        redisTemplate.opsForValue().set(key, user);
        System.out.println(redisTemplate.opsForValue().get(key));
        System.out.println(redisTemplate.opsForValue().get("name"));
    }



}
